$(document).ready(function(){	
	$('#data').fdatepicker({
		format: 'dd/mm/yyyy'
	});
	
	var nowTemp = new Date();
	var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
	
	var checkin = $('#data_inicio').fdatepicker({
		format: 'dd/mm/yyyy',
		onRender: function (date) {
			return date.valueOf() < now.valueOf() ? 'enabled' : '';
		}
	}).on('changeDate', function (ev) {
		if (ev.date.valueOf() > checkout.date.valueOf()) {
			var newDate = new Date(ev.date);
			newDate.setDate(newDate.getDate());
			checkout.update(newDate);
		}
		checkin.hide();
		$('#data_final')[0].focus();
	}).data('datepicker');
	var checkout = $('#data_final').fdatepicker({
		format: 'dd/mm/yyyy',
		onRender: function (date) {
			return date.valueOf() < checkin.date.valueOf() ? 'disabled' : '';
		}
	}).on('changeDate', function (ev) {
		checkout.hide();
	}).data('datepicker');
});